Commit e5874fbc authored by Tejesh's avatar Tejesh 🖖

tests

parent c746d431
Pipeline #91110 failed with stage
in 1 minute and 4 seconds
......@@ -115,7 +115,7 @@
scale = d3.scaleOrdinal(d3.schemeCategory10)
.domain(['weirdcraft', 'weirdcraft2', ...d3.extent(data, function (d) { return d.age })])
// New age number from first row will map to 3rd color of Category10 scheme
// t.equal(result, scale('weirdcraft'))
t.equal(result, scale('weirdcraft'))
// If domain is not provided, for ordinal scale -> set distinct values as domain
g1_scale = g1.scale(data, {
......@@ -125,7 +125,7 @@
});
result = g1_scale(d3.extent(data, (d) => d.age)[0])
scale = d3.scaleOrdinal(d3.schemeCategory10)
// t.equal(result, scale(data[0].age))
t.equal(result, scale(data[0].age))
band_count_scale = g1.scale([{ age: 'u' }, { age: 'a' }, { age: 's' }], {
metric: 'age',
......@@ -134,9 +134,9 @@
count: 3
})
// t.equal(band_count_scale('apple'), d3.schemePurples[3][0], 'apple')
// t.equal(band_count_scale('orange'), d3.schemePurples[3][1], 'orange')
// t.equal(band_count_scale('grapes'), d3.schemePurples[3][2], 'grapes')
t.equal(band_count_scale('apple'), d3.schemePurples[3][0], 'apple')
t.equal(band_count_scale('orange'), d3.schemePurples[3][1], 'orange')
t.equal(band_count_scale('grapes'), d3.schemePurples[3][2], 'grapes')
band_count_scale_no_metric = g1.scale(data, {
metric: 'age',
......@@ -146,9 +146,9 @@
count: 3
})
// t.equal(band_count_scale_no_metric('apple'), d3.schemePurples[3][0], 'apple')
// t.equal(band_count_scale_no_metric('orange'), d3.schemePurples[3][1], 'orange')
// t.equal(band_count_scale_no_metric('grapes'), d3.schemePurples[3][2], 'grapes')
t.equal(band_count_scale_no_metric('apple'), d3.schemePurples[3][0], 'apple')
t.equal(band_count_scale_no_metric('orange'), d3.schemePurples[3][1], 'orange')
t.equal(band_count_scale_no_metric('grapes'), d3.schemePurples[3][2], 'grapes')
var quantile_scale = g1.scale([{ age: 1 }, { age: 2 }, { age: 100 }], {
metric: 'age',
......@@ -172,9 +172,9 @@
reverse: true
})
// t.equal(reverse_quantile_scale({ age: 1 }), d3.schemePurples[3][2], 'reverse quantile scale 1 [0-33, 33-66, 66-100] ')
// t.equal(reverse_quantile_scale({ age: 2 }), d3.schemePurples[3][1], 'reverse quantile scale 2 [0-33, 33-66, 66-100] ')
// t.equal(reverse_quantile_scale({ age: 100 }), d3.schemePurples[3][0], 'reverse quantile scale 3 [0-33, 33-66, 66-100] ')
t.equal(reverse_quantile_scale({ age: 1 }), d3.schemePurples[3][2], 'reverse quantile scale 1 [0-33, 33-66, 66-100] ')
t.equal(reverse_quantile_scale({ age: 2 }), d3.schemePurples[3][1], 'reverse quantile scale 2 [0-33, 33-66, 66-100] ')
t.equal(reverse_quantile_scale({ age: 100 }), d3.schemePurples[3][0], 'reverse quantile scale 3 [0-33, 33-66, 66-100] ')
// Quantile takes domain from metric in dataset
......@@ -190,63 +190,57 @@
count: 3
})
// t.equal(quantize_scale({age: 30}), d3.schemePurples[3][2], 'reverse quantize scale 1 [0-33, 33-66, 66-100] ')
// t.equal(quantize_scale({age: 55}), d3.schemePurples[3][1], 'reverse quantize scale 2 [0-33, 33-66, 66-100] ')
// t.equal(quantize_scale({age: 70}), d3.schemePurples[3][0], 'reverse quantize scale 3 [0-33, 33-66, 66-100] ')
t.equal(quantize_scale({ age: 30 }), d3.schemePurples[3][2], 'reverse quantize scale 1 [0-33, 33-66, 66-100] ')
t.equal(quantize_scale({ age: 55 }), d3.schemePurples[3][1], 'reverse quantize scale 2 [0-33, 33-66, 66-100] ')
t.equal(quantize_scale({ age: 70 }), d3.schemePurples[3][0], 'reverse quantize scale 3 [0-33, 33-66, 66-100] ')
quantize_scale = g1.scale(data, {
metric: 'age',
domain: [0, 100],
scale: 'Quantize',
scheme: 'schemeBlues',
count: 4,
range: ['#ffffff', '#000000']
})
t.end()
})
t.equal(quantize_scale({age: 20}), '#ffffff')
t.equal(quantize_scale({age: 50}), '#000000')
t.equal(quantize_scale({age: 100}), '#000000')
t.equal(quantize_scale({ age: 20 }), '#ffffff')
t.equal(quantize_scale({ age: 50 }), '#000000')
t.equal(quantize_scale({ age: 100 }), '#000000')
quantize_scale = g1.scale(data, {
metric: 'age',
domain: [0, 100],
scale: 'Quantize',
scheme: 'schemeBlues',
count: 4,
range: ['#ffffff', '#000000'],
reverse: true
})
quantize_scale = g1.scale(data, {
metric: 'age',
domain: [0, 100],
scale: 'Quantize',
scheme: 'schemeBlues',
count: 4,
range: ['#ffffff', '#000000'],
reverse: true
})
t.equal(quantize_scale({ age: 20 }), '#000000')
t.equal(quantize_scale({ age: 50 }), '#ffffff')
t.equal(quantize_scale({ age: 100 }), '#ffffff')
t.equal(quantize_scale({age: 20}), '#000000')
t.equal(quantize_scale({age: 50}), '#ffffff')
t.equal(quantize_scale({age: 100}), '#ffffff')
quantize_scale = g1.scale(data, {
metric: 'age',
domain: [0, 100],
scale: 'Quantize',
scheme: 'schemeCategory10',
range: ['#ffffff', '#000000'],
reverse: true
})
metric: 'age',
domain: [0, 100],
scale: 'Quantize',
scheme: 'schemeCategory10',
range: ['#ffffff', '#000000'],
reverse: true
})
linear_scale = g1.scale([{age: 1}, {age: 70}, {age: 100}], {
linear_scale = g1.scale([{ age: 1 }, { age: 70 }, { age: 100 }], {
metric: 'age',
//scale: 'linear',
scheme: 'Blues'
})
t.equal(linear_scale({age: 1}), 'rgb(247, 251, 255)')
t.equal(linear_scale({age: 100}), 'rgb(8, 48, 107)')
ordinal_default_domain = g1.scale([{fruit: 1}, {fruit: 10}, {fruit: 30}], {
t.equal(linear_scale({ age: 1 }), 'rgb(247, 251, 255)')
t.equal(linear_scale({ age: 100 }), 'rgb(8, 48, 107)')
ordinal_default_domain = g1.scale([{ fruit: 1 }, { fruit: 10 }, { fruit: 30 }], {
metric: 'fruit',
scale: 'ordinal',
scheme: 'Blues'
})
t.equal(ordinal_default_domain({fruit: 1}), '#ffffff')
t.equal(ordinal_default_domain({ fruit: 1 }), '#ffffff')
t.end()
})
})
</script>
</body>
</html>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment