File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ export class Coordinate2D extends Coordinate {
114114 * @static
115115 * @param {string } str The string to convert
116116 * @returns {Coordinate2D } The 2D Coordinate
117+ * @throws {SyntaxError } If the string is invalid.
118+ * @example
119+ * Coordinate2D.fromString('[1, 2]')
117120 */
118121 static fromString ( str ) {
119122 if ( ! str || typeof ( str ) !== 'string' )
@@ -204,6 +207,8 @@ export class Coordinate3D extends Coordinate {
204207 * @static
205208 * @param {string } str The string to convert
206209 * @returns {Coordinate3D } The 3D Coordinate
210+ * @example
211+ * Coordinate3D.fromString('[1, 2, 3]')
207212 */
208213 static fromString ( str ) {
209214 if ( ! str || typeof ( str ) !== 'string' )
Original file line number Diff line number Diff line change @@ -39,6 +39,24 @@ describe('coordinates', () => {
3939 expect ( c ) . toEqual ( Coordinate3D . zero )
4040 } )
4141
42+ test ( 'zero 2D' , ( ) => {
43+ expect ( Coordinate2D . zero . toString ( ) ) . toBe ( '[0, 0]' )
44+ } )
45+
46+ test ( 'zero 3D' , ( ) => {
47+ expect ( Coordinate3D . zero . toString ( ) ) . toBe ( '[0, 0, 0]' )
48+ } )
49+
50+ test ( 'toString 2D' , ( ) => {
51+ const c = new Coordinate2D ( 2 , 3 )
52+ expect ( c . toString ( ) ) . toBe ( '[2, 3]' )
53+ } )
54+
55+ test ( 'toString 3D' , ( ) => {
56+ const c = new Coordinate3D ( 2 , 3 , 4 )
57+ expect ( c . toString ( ) ) . toBe ( '[2, 3, 4]' )
58+ } )
59+
4260 test ( 'fromString 2D' , ( ) => {
4361 let c = Coordinate2D . fromString ( '[2,3]' )
4462 expect ( c . x ) . toBe ( 2 )
You can’t perform that action at this time.
0 commit comments