Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Jun 28, 2024
1 parent 159554b commit cc570ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/nps.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { NpsVisualizer, NpsVisualizerWidget } from "../src/nps";

test("result resultMin resultMax", () => {
test("result resultMin resultMax", async () => {
const question: any = { type: "rating", name: "test" };
const data = [{ test: 1 }, { test: 10 }, { test: 8 }, { test: 7 }, { test: 9 }, { test: 9 }];
const nps = new NpsVisualizer(question, data);

let result = nps.getCalculatedValues();
let result: any = await nps.getCalculatedValues();

expect(result.total).toBe(6);
expect(result.detractors).toBe(1);
expect(result.passive).toBe(2);
expect(result.promoters).toBe(3);
});

test("result precision is 2 digits", () => {
test("result precision is 2 digits", async () => {
const question: any = { type: "rating", name: "test" };
const data = [{ test: 1 }, { test: 10 }, { test: 8 }, { test: 7 }, { test: 9 }, { test: 9 }];
const nps = new NpsVisualizer(question, data);
const calculations = nps.getCalculatedValues();
const widget = new NpsVisualizerWidget(nps, calculations);
const calculations = await nps.getCalculatedValues();
const widget = new NpsVisualizerWidget(nps, calculations as any);

expect(widget.npsScore).toBe(33.33);
expect(widget.detractorsPercent).toBe(16.67);
Expand Down

0 comments on commit cc570ed

Please sign in to comment.