Skip to content

Commit

Permalink
Updated builder and sku tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SnaBe committed Aug 27, 2024
1 parent e8a1157 commit 249b218
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
10 changes: 5 additions & 5 deletions test/builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe("size()", () => {
});
});

describe("get()", () => {
describe("getAllStrings()", () => {
test("should return zero elements when the StringBuilder is empty", () => {
// Arrange
const builder = new StringBuilder();

// Act
const result = builder.get();
const result = builder.getAllStrings();

// Assert
expect(result.length).toBe(0);
Expand All @@ -68,7 +68,7 @@ describe("get()", () => {
const builder = new StringBuilder(sku);

// Act
const result = builder.get();
const result = builder.getAllStrings();

// Assert
expect(result.length).toBe(4);
Expand All @@ -80,15 +80,15 @@ describe("get()", () => {
const builder = new StringBuilder(values);

// Act
const result = builder.get();
const result = builder.getAllStrings();

// Assert
expect(result.length).toBe(values.length);
});
});

describe("toString()", () => {
test("should return the orginal string if no seperator characters are present", () => {
test("should return the original string if no seperator characters are present", () => {
// Arrange
const text = "Spellbook Magazine";
const builder = new StringBuilder(text);
Expand Down
55 changes: 29 additions & 26 deletions test/sku.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import { describe, expect, test } from "@jest/globals";
import SKU from "../src/classes/sku";

describe("SKU.stringify()", () => {
test("should return the Strange Purple Energy Villain's Veil as SKU string", () => {
test("should return the Strange Purple Energy Villain's Veil as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 393,
quality: 5,
effect: 10,
elevated: true
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("393;5;u10;strange");
});

test("should return the Professional Festivized Australium Medi Gun as SKU string", () => {
test("should return the Professional Festivized Australium Medi Gun as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 211,
quality: 11,
australium: true,
Expand All @@ -29,31 +29,31 @@ describe("SKU.stringify()", () => {
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("211;11;australium;kt-3;festive");
});

test("should return the Conniver's Kunai Chemistry Set as SKU string", () => {
test("should return the Conniver's Kunai Chemistry Set as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 20006,
quality: 6,
output: 356,
outputQuality: 14
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("20006;6;od-356;oq-14");
});

test("should return the Hot Pacific Peacemaker War Paint (Well-Worn) as SKU string", () => {
test("should return the Hot Pacific Peacemaker War Paint (Well-Worn) as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 17419,
quality: 15,
effect: 701,
Expand All @@ -62,46 +62,46 @@ describe("SKU.stringify()", () => {
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("17419;15;u701;w4;pk419");
});

test("should return the Taunt: Conga Unusualifier as SKU string", () => {
test("should return the Taunt: Conga Unusualifier as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 9258,
quality: 5,
craftable: false,
target: 1118
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("9258;5;uncraftable;td-1118");
});

test("should return the Mann Co. Supply Munition #83 as SKU string", () => {
test("should return the Mann Co. Supply Munition #83 as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 9258,
quality: 6,
crateseries: 83
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("9258;6;c83");
});

test("should return the Professional Axtinguisher Kit Fabricator as SKU string", () => {
test("should return the Professional Axtinguisher Kit Fabricator as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 20003,
quality: 6,
killstreak: 3,
Expand All @@ -111,33 +111,36 @@ describe("SKU.stringify()", () => {
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("20003;6;kt-3;td-38;od-6526;oq-6");
});

test("should return the #67 Bruiser's Bandanna as SKU string", () => {
test("should return the #67 Bruiser's Bandanna as a SKU string", () => {
// Arrange
const values = {
const item = {
defindex: 30397,
quality: 6,
craftnumber: 67
}

// Act
const result = SKU.stringify(values);
const result = SKU.stringify(item);

// Assert
expect(result).toBe("30397;6;n67");
});

test("should throw if the SKU object is empty", () => {
test("should return the default SKU string if the object is empty", () => {
// Arrange
const empty = Object.create(Object.prototype);

// Act
const sku = SKU.stringify(empty);

// Act and assert
expect(() => SKU.stringify(empty)).toThrow(RangeError);
expect(sku).toBe("0;0");
});
});

Expand Down

0 comments on commit 249b218

Please sign in to comment.