-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy patharray-test.js
More file actions
32 lines (24 loc) · 1.22 KB
/
array-test.js
File metadata and controls
32 lines (24 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { moduleFor, test } from 'ember-qunit';
moduleFor('transform:array', 'Unit | Transform | array', {
// Specify the other units that are required for this test.
// needs: ['serializer:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
let transform = this.subject();
assert.ok(transform);
});
test('it serializes properly', function(assert) {
assert.expect(4);
let transform = this.subject();
assert.deepEqual(transform.serialize(['a', 'b', 'c', 'd']), ['a', 'b', 'c', 'd'], 'Arrays are serialized into arrays');
assert.deepEqual(transform.serialize('a, b , c, d'), ['a', 'b', 'c', 'd'], 'Strings of items with "," separaters are serialized into arrays with the items trimmed');
assert.deepEqual(transform.serialize(1), [], 'Numbers are serialized into an empty array');
assert.deepEqual(transform.serialize(true), [], 'Booleans are serialized into an empty array');
});
test('it deserializes properly', function(assert) {
assert.expect(2);
let transform = this.subject();
assert.deepEqual(transform.deserialize([1, 2, 3]), [1, 2, 3], 'Arrays get deserialized into arrays');
assert.deepEqual(transform.deserialize('a,b,c'), [], 'Anything else just becomes an empty array');
});