diff --git a/exercises/practice/resistor-color-trio/.meta/config.json b/exercises/practice/resistor-color-trio/.meta/config.json index 397ef24e81..403b20a7fc 100644 --- a/exercises/practice/resistor-color-trio/.meta/config.json +++ b/exercises/practice/resistor-color-trio/.meta/config.json @@ -3,7 +3,8 @@ "SleeplessByte" ], "contributors": [ - "hayashi-ay" + "hayashi-ay", + "jagdish-15" ], "files": { "solution": [ diff --git a/exercises/practice/resistor-color-trio/.meta/proof.ci.js b/exercises/practice/resistor-color-trio/.meta/proof.ci.js index b421b68d4a..3b89a4d607 100644 --- a/exercises/practice/resistor-color-trio/.meta/proof.ci.js +++ b/exercises/practice/resistor-color-trio/.meta/proof.ci.js @@ -12,6 +12,8 @@ const COLORS = [ ]; const ONE_KILOOHM = 1000; +const ONE_MEGAOHM = 1000000; +const ONE_GIGAOHM = 1000000000; class ArgumentError extends Error {} @@ -44,9 +46,18 @@ export class ResistorColorTrio { toString() { const value = this.value; - return value < ONE_KILOOHM - ? `${value} ohms` - : `${Math.floor(value / ONE_KILOOHM)} kiloohms`; + + if (value >= ONE_GIGAOHM) { + return `${Math.floor(value / ONE_GIGAOHM)} gigaohms`; + } + if (value >= ONE_MEGAOHM) { + return `${Math.floor(value / ONE_MEGAOHM)} megaohms`; + } + if (value >= ONE_KILOOHM) { + return `${Math.floor(value / ONE_KILOOHM)} kiloohms`; + } + + return `${value} ohms`; } /** diff --git a/exercises/practice/resistor-color-trio/.meta/tests.toml b/exercises/practice/resistor-color-trio/.meta/tests.toml index beabab3df5..b7d45fa5d5 100644 --- a/exercises/practice/resistor-color-trio/.meta/tests.toml +++ b/exercises/practice/resistor-color-trio/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [d6863355-15b7-40bb-abe0-bfb1a25512ed] description = "Orange and orange and black" @@ -16,3 +23,18 @@ description = "Green and brown and orange" [f5d37ef9-1919-4719-a90d-a33c5a6934c9] description = "Yellow and violet and yellow" + +[5f6404a7-5bb3-4283-877d-3d39bcc33854] +description = "Blue and violet and blue" + +[7d3a6ab8-e40e-46c3-98b1-91639fff2344] +description = "Minimum possible value" + +[ca0aa0ac-3825-42de-9f07-dac68cc580fd] +description = "Maximum possible value" + +[0061a76c-903a-4714-8ce2-f26ce23b0e09] +description = "First two colors make an invalid octal number" + +[30872c92-f567-4b69-a105-8455611c10c4] +description = "Ignore extra colors" diff --git a/exercises/practice/resistor-color-trio/resistor-color-trio.spec.js b/exercises/practice/resistor-color-trio/resistor-color-trio.spec.js index b1aa227af4..26562bd05b 100644 --- a/exercises/practice/resistor-color-trio/resistor-color-trio.spec.js +++ b/exercises/practice/resistor-color-trio/resistor-color-trio.spec.js @@ -36,6 +36,36 @@ describe('Resistor Color Trio', () => { ); }); + xtest('Blue and violet and blue', () => { + expect(new ResistorColorTrio(['blue', 'violet', 'blue']).label).toEqual( + makeLabel({ value: 67, unit: 'megaohms' }), + ); + }); + + xtest('Minimum possible value', () => { + expect(new ResistorColorTrio(['black', 'black', 'black']).label).toEqual( + makeLabel({ value: 0, unit: 'ohms' }), + ); + }); + + xtest('Maximum possible value', () => { + expect(new ResistorColorTrio(['white', 'white', 'white']).label).toEqual( + makeLabel({ value: 99, unit: 'gigaohms' }), + ); + }); + + xtest('First two colors make an invalid octal number', () => { + expect(new ResistorColorTrio(['black', 'grey', 'black']).label).toEqual( + makeLabel({ value: 8, unit: 'ohms' }), + ); + }); + + xtest('Ignore extra colors', () => { + expect( + new ResistorColorTrio(['blue', 'green', 'yellow', 'orange']).label, + ).toEqual(makeLabel({ value: 650, unit: 'kiloohms' })); + }); + // optional: error xtest('Invalid color', () => { expect(