diff --git a/src/index.ts b/src/index.ts index b7d5c0a..41ed852 100644 --- a/src/index.ts +++ b/src/index.ts @@ -121,8 +121,20 @@ export class Format { stringify( attributes: StrigifySKUAttributes | ItemAttributes, + options: StringifyOptions & { useDefindexes: true } + ): string; + stringify( + sku: string, + options: StringifyOptions & { useDefindexes: true } + ): string; + stringify( + attributesOrSku: StrigifySKUAttributes | ItemAttributes | string, options: StringifyOptions = {} ): string { + const attributes = + typeof attributesOrSku === 'string' + ? parseSKU(attributesOrSku) + : attributesOrSku; return stringify(this.schema, attributes, options); } diff --git a/test/stringify.js b/test/stringify.js index 7e67121..6518ff1 100644 --- a/test/stringify.js +++ b/test/stringify.js @@ -550,13 +550,13 @@ describe('stringify from defindexes and numbers.', () => { it('Case #32 - Red Rock Roscoe texture', () => { const itemString = stringify({ name: 'Pistol', quality: 'Decorated Weapon', craftable: true, wear: 'Field-Tested', festivized: true, killstreak: 'Specialized Killstreak', texture: 0 }); - assert.equal(itemString, 'Festivized Specialized Killstreak Red Rock Roscoe Pistol (Field-Tested)'); + assert.equal(itemString, 'Festivized Specialized Killstreak Red Rock Roscoe Pistol (Field-Tested)'); }); it('Case #33 - Bat', () => { const itemString = stringify({ defindex: 0, quality: 'Unique', craftable: true }); - assert.equal(itemString, 'Bat'); + assert.equal(itemString, 'Bat'); }) it('Case #34 - Bat output', () => { @@ -605,3 +605,17 @@ describe('stringify from defindexes and numbers.', () => { assert.deepEqual(itemString, "Haunted Kraken Rotation Sensation"); }); }); + +describe("stringify SKU", () => { + it("Case #1", () => { + const itemString = stringify("5050;6"); + + assert.equal(itemString, "Backpack Expander"); + }); + + it("Case #2", () => { + const itemString = stringify("1071;11;kt-3"); + + assert.equal(itemString, "Strange Professional Killstreak Golden Frying Pan"); + }); +}) \ No newline at end of file