-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathad_test.ts
65 lines (62 loc) · 1.66 KB
/
ad_test.ts
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
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import { akvaplanistFromAdPerson } from "./ad.ts";
import { AkvaplanAdPerson } from "./ad_types.ts";
const xyz: AkvaplanAdPerson = {
ExtensionAttribute1: "?",
sAMAccountName: "xyz",
GivenName: "Xx",
Sn: "Yz",
Mail: "[email protected]",
Title: "Position",
extensionAttribute4: "Stilling",
ExtensionAttribute3: "Ansvarsområde",
ExtensionAttribute5: "Responsibility ",
ExtensionAttribute2: "",
Department: "LEDELS",
city: "Tromsø",
physicalDeliveryOfficeName: "Ignored",
telephoneNumber: "+47 999 88 777",
"msRTCSIP-PrimaryUserAddress": "sip:[email protected]",
whencreated: "09.02.2022 16:49:21",
APNStartDate: "",
accountExpires: "0",
};
const expected = {
family: "Yz",
given: "Xx",
id: "xyz",
tel: "+4799988777",
workplace: "Tromsø",
country: "NO",
from: undefined,
expired: undefined,
"responsibility": {
"en": "Responsibility",
"no": "Ansvarsområde",
},
"section": "LEDELS",
"management": true,
"position": { "en": "Position", "no": "Stilling" },
"created": new Date("2022-02-09T15:49:21.000Z"),
"updated": new Date(0),
};
Deno.test(function akvaplanistFromAdPersonTest() {
assertEquals(
akvaplanistFromAdPerson(xyz),
expected,
);
assertEquals(
akvaplanistFromAdPerson({ ...xyz, city: "Reykjavik" }).country,
"IS",
);
assertEquals(
akvaplanistFromAdPerson({ ...xyz, accountExpires: "133532028000000000" })
.expired,
new Date("2024-02-23T23:00:00.000Z"),
);
assertEquals(
akvaplanistFromAdPerson({ ...xyz, accountExpires: "999589016000000000" })
.expired,
undefined,
);
});