<commit_before>Feature: Enums

As a Node.js + TypeScript + node-java developer
I want to understand how to use Java enum types in Typescript.

  Background:
    Given this boilerplate to intialize node-java:
    """
    /// <reference path='../../typings/power-assert/power-assert.d.ts' />
    /// <reference path='../../typings/lodash/lodash.d.ts' />
    /// <reference path='../../typings/node/node.d.ts' />
    /// <reference path='../../typings/glob/glob.d.ts' />
    /// <reference path='../../featureset/java.d.ts'/>

    import _ = require('lodash');
    import glob = require('glob');
    import java = require('java');
    import assert = require('power-assert');

    var filenames = glob.sync('featureset/target/**/*.jar');
    filenames.forEach((name: string) => { java.classpath.push(name); });

    var AnEnum = java.import('com.redseal.featureset.AnEnum');
    {{{ scenario_snippet }}}

    """

  Scenario: static members
    Given the above boilerplate with following scenario snippet:
    """
    var miles: Java.AnEnum = AnEnum.miles;
    var monk: Java.AnEnum = AnEnum.monk;
    assert.ok(miles);
    assert.ok(monk);
    assert.ok(java.instanceOf(miles, 'com.redseal.featureset.AnEnum'));
    assert.ok(java.instanceOf(miles, 'java.lang.Enum'));
    assert.ok(!miles.equalsSync(monk));
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: values()
    Given the above boilerplate with following scenario snippet:
    """
    var enums: Java.AnEnum[] = AnEnum.valuesSync();
    assert.ok(_.isArray(enums));
    var ids: string[] = _.map(enums, (e: Java.AnEnum) => e.toStringSync());
    assert.deepEqual(ids, [ 'mingus', 'monk', 'miles' ]);
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: valueOf()
    Given the above boilerplate with following scenario snippet:
    """
    var miles: Java.AnEnum = AnEnum.valueOfSync('miles');
    var monk: Java.AnEnum = AnEnum.valueOfSync('monk');
    assert.ok(miles.equalsSync(AnEnum.miles));
    assert.ok(monk.equalsSync(AnEnum.monk));
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: static member typo fails
    Given the above boilerplate with following scenario snippet:
    """
    var myles: Java.AnEnum = AnEnum.myles;<commit_msg>Add an enum scenario showing javacript === cannot be used to compare enums.<commit_after>Feature: Enums

As a Node.js + TypeScript + node-java developer
I want to understand how to use Java enum types in Typescript.

  Background:
    Given this boilerplate to intialize node-java:
    """
    /// <reference path='../../typings/power-assert/power-assert.d.ts' />
    /// <reference path='../../typings/lodash/lodash.d.ts' />
    /// <reference path='../../typings/node/node.d.ts' />
    /// <reference path='../../typings/glob/glob.d.ts' />
    /// <reference path='../../featureset/java.d.ts'/>

    import _ = require('lodash');
    import glob = require('glob');
    import java = require('java');
    import assert = require('power-assert');

    var filenames = glob.sync('featureset/target/**/*.jar');
    filenames.forEach((name: string) => { java.classpath.push(name); });

    var AnEnum = java.import('com.redseal.featureset.AnEnum');
    {{{ scenario_snippet }}}

    """

  Scenario: static members
    Given the above boilerplate with following scenario snippet:
    """
    var miles: Java.AnEnum = AnEnum.miles;
    var monk: Java.AnEnum = AnEnum.monk;
    assert.ok(miles);
    assert.ok(monk);
    assert.ok(java.instanceOf(miles, 'com.redseal.featureset.AnEnum'));
    assert.ok(java.instanceOf(miles, 'java.lang.Enum'));
    assert.ok(!miles.equalsSync(monk));
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: values()
    Given the above boilerplate with following scenario snippet:
    """
    var enums: Java.AnEnum[] = AnEnum.valuesSync();
    assert.ok(_.isArray(enums));
    var ids: string[] = _.map(enums, (e: Java.AnEnum) => e.toStringSync());
    assert.deepEqual(ids, [ 'mingus', 'monk', 'miles' ]);
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: must use java Object.equals to compare enum values
    Given the above boilerplate with following scenario snippet:
    """
    var miles: Java.AnEnum = AnEnum.valueOfSync('miles');
    var milesAgain: Java.AnEnum = AnEnum.valueOfSync('miles');

    var sameWithJavaObjectEquals: boolean = miles.equalsSync(milesAgain);
    assert( sameWithJavaObjectEquals );

    var sameWithJavascriptEquals: boolean = miles === milesAgain;
    assert( !sameWithJavascriptEquals );
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: valueOf()
    Given the above boilerplate with following scenario snippet:
    """
    var miles: Java.AnEnum = AnEnum.valueOfSync('miles');
    var monk: Java.AnEnum = AnEnum.valueOfSync('monk');
    assert.ok(miles.equalsSync(AnEnum.miles));
    assert.ok(monk.equalsSync(AnEnum.monk));
    """
    Then it compiles and lints cleanly
    And it runs and produces no output

  Scenario: static member typo fails
    Given the above boilerplate with following scenario snippet:
    """
    var myles: Java.AnEnum = AnEnum.myles;
{'fraction_non_alphanumeric': 0.1435820334523586, 'fraction_numerical': 0.0, 'mean_word_length': 3.207114624505929, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6698377', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1627, 'n_words': 434}