summaryrefslogtreecommitdiff
path: root/src/fauxton/test/jasmine/spec/example.js
blob: f56f6e9ca6b7da9a692b1450cf8385a1c1ab066b (plain)
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
describe("one tautology", function() {
  it("is a tautology", function() {
    expect(true).toBeTruthy();
  });

  describe("is awesome", function() {
    it("is awesome", function() {
      expect(1).toBe(1);
    });
  });
});

describe("simple tests", function() {
  it("increments", function() {
    var mike = 0;

    expect(mike++ === 0).toBeTruthy();
    expect(mike === 1).toBeTruthy();
  });

  it("increments (improved)", function() {
    var mike = 0;

    expect(mike++).toBe(0);
    expect(mike).toBe(1);
  });
});

describe("setUp/tearDown", function() {
  beforeEach(function() {
    // console.log("Before");
  });

  afterEach(function() {
    // console.log("After");
  });

  it("example", function() {
    // console.log("During");
  });

  describe("setUp/tearDown", function() {
    beforeEach(function() {
      // console.log("Before2");
    });

    afterEach(function() {
      // console.log("After2");
    });

    it("example", function() {
      // console.log("During Nested");
    });
  });
});

describe("async", function() {
  it("multiple async", function() {
    var semaphore = 2;

    setTimeout(function() {
      expect(true).toBeTruthy();
      semaphore--;
    }, 500);

    setTimeout(function() {
      expect(true).toBeTruthy();
      semaphore--;
    }, 500);

    waitsFor(function() { return semaphore === 0; });
  });
});