This repository was archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathassignment-tests.js
More file actions
80 lines (60 loc) · 1.88 KB
/
assignment-tests.js
File metadata and controls
80 lines (60 loc) · 1.88 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import test from 'tape';
import { compose } from '../../src/utils';
const assignmentProps = [
'methods',
'properties',
'deepProperties',
'staticProperties',
'deepStaticProperties'
];
const build = (num) => {
const composable = function () {};
composable.compose = function () {};
assignmentProps.forEach(prop => {
composable.compose[prop] = {
[num]: num,
override: num
};
});
return composable;
};
// Loop over each property that is copied by assignment and ensure
// that copy and priority are implemented correctly.
assignmentProps.forEach(prop => {
test(`${ prop } assignment 1`, (assert) => {
const subject = compose(build(1), build(2));
const props = subject.compose;
const actual = props[prop][1];
const expected = 1;
assert.equal(actual, expected,
`${ prop } should be copied by assignment from first argument`);
assert.end();
});
test(`${ prop } assignment 2`, (assert) => {
const subject = compose(build(1), build(2));
const props = subject.compose;
const actual = props[prop][2];
const expected = 2;
assert.equal(actual, expected,
`${ prop } should be copied by assignment from 2nd argument`);
assert.end();
});
test(`${ prop } assignment 3`, (assert) => {
const subject = compose(build(1), build(2), build(3));
const props = subject.compose;
const actual = props[prop][3];
const expected = 3;
assert.equal(actual, expected,
`${ prop } should be copied by assignment from subsequent arguments`);
assert.end();
});
test(`${ prop } assignment priority`, (assert) => {
const subject = compose(build(1), build(2));
const props = subject.compose;
const actual = props[prop].override;
const expected = 2;
assert.equal(actual, expected,
`${ prop } should be copied by assignment with last-in priority`);
assert.end();
});
});