This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
test.js
75 lines (59 loc) · 2.78 KB
/
test.js
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
$(function() {
test('Single item with no vocabulary and one property', function() {
var res = $.microdata.parseElement($('#single-item-no-vocabulary'));
same(res, {
type: null,
properties: [
{ name: "description", value: "This is a description", valid: true }
],
valid: true, missing: []
}, 'Should return null type, one property');
});
test('Single item with vocabulary and no properties', function() {
same($.microdata.parseElement($('#vocab-no-properties')), {
type: "http://example.org/Type",
properties: [],
valid: true, missing: []
}, 'Should have type set to example.org');
});
test('Multiple values for single property', function() {
same($.microdata.parseElement($('#multi-value-single-prop')), {
type: "http://example.org/Multivalue",
properties: [
{ name: "attending", value: "Peter Bishop", valid: true },
{ name: "attending", value: "Walter Bishop", valid: true }
],
valid: true, missing: []
}, 'Should return an array of values');
});
test('Multiple properties for single value', function() {
same($.microdata.parseElement($('#multi-prop-single-value')), {
type: "http://example.org/Multiprop",
properties: [
{ name: "admin", value: "true", valid: true },
{ name: "user", value: "true", valid: true }
],
valid: true, missing: []
}, 'Should return multiple properties with same value');
});
test('Single item with 1 missing property per vocabulary rules', function() {
same($.microdata.parseElement($('#single-item-missing-property')), {
type: "http://data-vocabulary.org/Event",
properties: [
{ name: "summary", value: "This is the event summary", valid: true }
],
missing: [ "startdate" ],
valid: false
}, 'Should return 1 good property and one missing');;
});
test('Single item with 1 invalid property per vocabulary rules', function() {
same($.microdata.parseElement($('#single-item-invalid-property')), {
type: "http://data-vocabulary.org/Event",
properties: [
{ name: "summary", value: "Event summary", valid: true },
{ name: "startdate", value: "2011-08-05x", valid: false }
],
missing: [], valid: false
}, 'Should return 1 invalid property and invalid object');
});
});