1
+ import { expect } from 'chai' ;
2
+ import day2 from '../src/day2' ;
3
+
4
+ describe ( 'day2 tests' , ( ) => {
5
+ describe ( 'check data type' , ( ) => {
6
+ it ( 'should return undefined when no parameters are passed' , ( ) => {
7
+ expect ( day2 ( ) ) . to . be . undefined ;
8
+ } ) ;
9
+
10
+ it ( 'should return a string when a string is passed' , ( ) => {
11
+ expect ( day2 ( 'a string' ) ) . to . be . a ( 'string' ) ;
12
+ } ) ;
13
+
14
+ it ( 'should return a number when a number is passed' , ( ) => {
15
+ expect ( day2 ( 10 ) ) . to . be . a ( 'Number' ) ;
16
+ } ) ;
17
+
18
+ it ( 'should not be a string when a number is passed' , ( ) => {
19
+ expect ( day2 ( 10 ) ) . to . not . be . a ( 'string' ) ;
20
+ } ) ;
21
+ } ) ;
22
+
23
+ describe ( 'checking equals' , ( ) => {
24
+ it ( 'should equal the string passed' , ( ) => {
25
+ expect ( day2 ( 'same string' ) ) . to . equal ( 'same string' ) ;
26
+ } ) ;
27
+
28
+ it ( 'should deep equal the object passed' , ( ) => {
29
+ const givenObject = {
30
+ hello : 'world'
31
+ } ;
32
+
33
+ expect ( day2 ( givenObject ) ) . to . deep . equal ( givenObject ) ;
34
+ } ) ;
35
+ } ) ;
36
+
37
+ describe ( 'checking contains' , ( ) => {
38
+ it ( 'should contain part of the string passed' , ( ) => {
39
+ const givenString = 'hello world' ;
40
+
41
+ expect ( day2 ( givenString ) ) . to . contain ( 'world' ) ;
42
+ } ) ;
43
+ } ) ;
44
+
45
+ describe ( 'checking errors' , ( ) => {
46
+ it ( 'should throw an error when "error" is passed' , ( ) => {
47
+ function wrappedFunction ( ) {
48
+ day2 ( 'error' ) ;
49
+ }
50
+
51
+ expect ( wrappedFunction ) . to . throw ( 'Cannot pass error' ) ;
52
+ } ) ;
53
+ } ) ;
54
+ } ) ;
0 commit comments