Skip to content

Commit 85ebeb3

Browse files
author
Edward Smit
committed
Merge pull request #29 from chaijs/feature/format-tests
Re-format test-data
2 parents 46d2b54 + a76f528 commit 85ebeb3

File tree

2 files changed

+122
-125
lines changed

2 files changed

+122
-125
lines changed

test/fail.js

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,97 +40,93 @@
4040
this.assert(
4141
err instanceof chai.AssertionError
4242
, message + ' expected #{this} to fail, but it threw ' + inspect(err));
43-
/*this.assert(
44-
err.message === message
45-
, 'expected #{this} to fail with ' + inspect(message) + ', but got ' + inspect(err.message));*/
4643
return;
4744
}
4845

4946
this.assert(false, message + ' expected #{this} to fail');
5047
});
5148
});
52-
var tests = [];
53-
tests.push({
49+
var tests = [{
5450
name: 'properties',
5551
schema: {
56-
"properties": {
57-
"intKey": {
58-
"type": "integer"
52+
properties: {
53+
intKey: {
54+
type: 'integer'
5955
},
60-
"stringKey": {
61-
"type": "string"
56+
stringKey: {
57+
type: 'string'
6258
}
6359
}
6460
},
65-
valid: [
66-
{ data: {
67-
"intKey": 1,
68-
"stringKey": "one"
69-
}}
70-
],
71-
invalid: [
72-
{data: {
73-
"intKey": 3,
74-
"stringKey": false
75-
}}
76-
]
61+
valid: [{
62+
data: {
63+
intKey: 1,
64+
stringKey: 'one'
65+
}
66+
}],
67+
invalid: [{
68+
data: {
69+
intKey: 3,
70+
stringKey: false
71+
}
72+
}]
7773
}, {
7874
name: 'combinations',
7975
schema: {
80-
"id": "any_v1",
81-
"anyOf": [
82-
{"type": "integer"},
83-
{"type": "string"}
76+
id: 'any_v1',
77+
anyOf: [
78+
{ type: 'integer' },
79+
{ type: 'string' }
8480
]
8581
},
8682
valid: [
87-
{ data: 1},
88-
{ data: "yo"}
83+
{ data: 1 },
84+
{ data: 'yo' }
8985
],
9086
invalid: [
91-
{ data: [1, 2, 3]},
92-
{ data: {aa: 1}}
87+
{ data: [1, 2, 3] },
88+
{ data: { aa: 1 } }
9389
]
9490
}, {
9591
name: 'fruit',
9692
schema: {
97-
"id": "fruit_v1",
98-
"description": "fresh fruit schema v1",
99-
"type": "object",
100-
"properties": {
101-
"required": ["skin", "colors", "taste"],
102-
"colors": {
103-
"type": "array",
104-
"minItems": 1,
105-
"uniqueItems": true,
106-
"items": {
107-
"type": "string"
93+
id: 'fruit_v1',
94+
description: 'fresh fruit schema v1',
95+
type: 'object',
96+
properties: {
97+
required: ['skin', 'colors', 'taste'],
98+
colors: {
99+
type: 'array',
100+
minItems: 1,
101+
uniqueItems: true,
102+
items: {
103+
type: 'string'
108104
}
109105
},
110-
"skin": {
111-
"type": "string"
106+
skin: {
107+
type: 'string'
112108
},
113-
"taste": {
114-
"type": "number",
115-
"minimum": 5
109+
taste: {
110+
type: 'number',
111+
minimum: 5
116112
}
117113
}
118114
},
119-
valid: [
120-
{ data: {
121-
skin: "thin",
122-
colors: ["red", "green", "yellow"],
115+
valid: [{
116+
data: {
117+
skin: 'thin',
118+
colors: ['red', 'green', 'yellow'],
123119
taste: 10
124-
}}
125-
],
126-
invalid: [
127-
{data: {
128-
colors: ["brown"],
120+
}
121+
}],
122+
invalid: [{
123+
data: {
124+
colors: ['brown'],
129125
taste: 0,
130126
worms: 2
131-
}}
132-
]
133-
});
127+
}
128+
}]
129+
}];
134130

135131
it('has tests', function () {
136132
assert.isArray(tests, 'tests');

test/suite.js

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -59,98 +59,99 @@
5959
});
6060

6161
describe('assertions', function () {
62-
var tests = [];
63-
tests.push({
62+
var tests = [{
6463
name: 'properties',
6564
schema: {
66-
"properties": {
67-
"intKey": {
68-
"type": "integer"
65+
properties: {
66+
intKey: {
67+
type: 'integer'
6968
},
70-
"stringKey": {
71-
"type": "string"
69+
stringKey: {
70+
type: 'string'
7271
}
7372
}
7473
},
75-
valid: [
76-
{ data: {
77-
"intKey": 1,
78-
"stringKey": "one"
79-
}}
80-
],
81-
invalid: [
82-
{data: {
83-
"intKey": 3,
84-
"stringKey": false
85-
}}
86-
]
87-
});
88-
tests.push({
74+
valid: [{
75+
data: {
76+
intKey: 1,
77+
stringKey: 'one'
78+
}
79+
}],
80+
invalid: [{
81+
data: {
82+
intKey: 3,
83+
stringKey: false
84+
}
85+
}]
86+
}, {
8987
name: 'fruit',
9088
schema: {
91-
"id": "fruit_v1",
92-
"description": "fresh fruit schema v1",
93-
"type": "object",
94-
"required": ["skin", "colors", "taste"],
95-
"properties": {
96-
"colors": {
97-
"type": "array",
98-
"minItems": 1,
99-
"uniqueItems": true,
100-
"items": {
101-
"type": "string"
89+
id: 'fruit_v1',
90+
description: 'fresh fruit schema v1',
91+
type: 'object',
92+
required: ['skin', 'colors', 'taste'],
93+
properties: {
94+
colors: {
95+
type: 'array',
96+
minItems: 1,
97+
uniqueItems: true,
98+
items: {
99+
type: 'string'
102100
}
103101
},
104-
"skin": {
105-
"type": "string"
102+
skin: {
103+
type: 'string'
106104
},
107-
"taste": {
108-
"type": "number",
109-
"minimum": 5
105+
taste: {
106+
type: 'number',
107+
minimum: 5
110108
},
111-
"worms": {
112-
"type": "number",
113-
"maximum": 1
109+
worms: {
110+
type: 'number',
111+
maximum: 1
114112
}
115113
}
116114
},
117-
valid: [
118-
{ data: {
119-
skin: "thin",
120-
colors: ["red", "green", "yellow"],
115+
valid: [{
116+
data: {
117+
skin: 'thin',
118+
colors: ['red', 'green', 'yellow'],
121119
taste: 10
122-
}},
123-
{ data: {
124-
skin: "thin",
125-
colors: ["yellow"],
120+
}
121+
}, {
122+
data: {
123+
skin: 'thin',
124+
colors: ['yellow'],
126125
taste: 5,
127126
worms: 1
128-
}}
129-
],
130-
invalid: [
131-
{ data: {
132-
skin: "thin",
133-
colors: ["yellow"],
127+
}
128+
}],
129+
invalid: [{
130+
data: {
131+
skin: 'thin',
132+
colors: ['yellow'],
134133
taste: 0
135-
}},
136-
{ data: {
137-
skin: "thin",
134+
}
135+
}, {
136+
data: {
137+
skin: 'thin',
138138
colors: [1, 2, 3],
139139
taste: 5
140-
}},
141-
{ data: {
140+
}
141+
}, {
142+
data: {
142143
skin: 321,
143-
colors: ["yellow"],
144+
colors: ['yellow'],
144145
taste: 5
145-
}},
146-
{ data: {
147-
skin: "thin",
148-
colors: ["yellow"],
146+
}
147+
}, { data: {
148+
skin: 'thin',
149+
colors: ['yellow'],
149150
taste: 5,
150151
worms: 3
151-
}}
152-
]
153-
});
152+
}
153+
}]
154+
}];
154155
describe('check test data', function () {
155156
it('has tests', function () {
156157
assert.isArray(tests, 'tests');

0 commit comments

Comments
 (0)